/*
 * @Descripttion:
 * @version:
 * @Author: kl2018
 * @Date: 2020-05-06 14:55:08
 * @LastEditors: kl2018
 * @LastEditTime: 2020-08-10 10:33:07
 */
import { observable, action, computed } from 'mobx';

export default class OdocCompsStore {
	/**
	 * 窗口的显示属性
	 */
  @observable dialogVisible = observable.map ? observable.map({}) : asMap({});

	/**
	 * 窗口是否初始化
	 */
  @observable dialogInit = observable.map ? observable.map({}) : asMap({});

	/**
	 * 窗口的基本信息，标题等
	 */
  @observable dialogParam = {};

	/**
	 * 流程的一些常用store
	 */
  @observable workflowStores = {};

  @computed get requestParam() {
    const { globalStore } = this.workflowStores;
    const { commonParam = {}, submitParam = {}, markInfo } = globalStore;
    const { workflowid, nodeid, formid, isbill, f_weaver_belongto_userid, f_weaver_belongto_usertype, creater, creatertype } = commonParam;
    // requestid从submitParam里获取，因为新建节点，新建成功后，不刷新页面，只能从submitParam里取
    const { requestid } = submitParam;

    return {
      requestid,
      workflowid,
      nodeid,
      formid,
      isbill,
      f_weaver_belongto_userid,
      f_weaver_belongto_usertype,
      creater,
      creatertype,
      markInfo,
    };
  }

  @action
  setDialogVisible = (key, value = false) => {
    if (value) {
      this.dialogInit.set(key, true);
    }

    this.dialogVisible.set(key, value);
  }

  @action
  setDialogParam(key, value = {}) {
    this.dialogParam[key] = value;
  }

  @action
  setWorkflowStores(stores = {}) {
    this.workflowStores = stores;
  }
}
